package com.longge;

public class SearchInsert {
    public int searchInsert(int[] nums, int target) {

        int left = 0, right = nums.length;

        while (left < right) {
            int mid = left + (right - left) / 2;
            if (nums[mid] >= target) {
                right = mid;
            } else if (nums[mid] < target) {
                left = mid;
            }
        }
        return right;
    }
}
